package com.xzlcPT.service.impl;

import com.github.pagehelper.PageHelper;
import com.util.PageBean;
import com.xzlcPT.bean.XzField;
import com.xzlcPT.dao.XzFieldMapper;
import com.xzlcPT.service.XzFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2017/7/10.
 */
@Service("fieldService")
public class XzFieldServiceImpl implements XzFieldService {

    @Autowired
    private XzFieldMapper fieldMapper;

    @Override
    public List<XzField> selectByType(int fieldType) {
        return fieldMapper.selectByType(fieldType);
    }

    @Override
    public void insertByName(List<XzField> xzFields) {
        fieldMapper.insertByName(xzFields);
    }

    @Override
    public void deleteByName(String name) {
        fieldMapper.deleteByNames(name);
    }

    @Override
    public PageBean<XzField> selAllByEmp(int page, int row, XzField xzField) {
        PageHelper.startPage(page,row);
        List<XzField> xzFieldList = fieldMapper.selAllByEmp(xzField);
        PageBean<XzField> pageBean = new PageBean<>(xzFieldList);
        return pageBean;
    }

    @Override
    public XzField selFieldById(Long fieldId) {
        XzField xzField = fieldMapper.selectByPrimaryKey(fieldId);
        return xzField;
    }

    @Override
    public int updateField(XzField xzField) {
        int i = fieldMapper.updateField(xzField);
        return i;
    }

}
